import logging

from rest_framework import views
from rest_framework import status
from rest_framework.response import Response
from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema

logger = logging.getLogger(__name__)


class IndexView(views.APIView):

    @swagger_auto_schema(
        operation_description="初始测试接口",
        responses={
            status.HTTP_200_OK: openapi.Response(
                description="测试成功",
                examples={
                    'application/json': {
                        'message': 'hello index'
                    }
                }
            )
        }
    )
    def get(self, request, *args, **kwargs):
        logger.info("index ok")
        return Response({"message": "hello index"}, status=status.HTTP_200_OK)